﻿using System;
using System.Windows;
using Flux.Editor.Extensions;

namespace Flux.Editor.Dialogs
{
	public partial class NewMapDialog
	{
		public string Name { get; set; }
		public int Width { get; set; }
		public int Height { get; set; }

		public NewMapDialog()
		{
			InitializeComponent();
		}

		private void BtnOk_OnClick(object sender, RoutedEventArgs e)
		{
			if (string.IsNullOrEmpty(txtName.Text))
			{
				MessageBox.Show("Map needs a name");
				return;
			}

			if (!txtTileWidth.Text.IsNumeric())
			{
				MessageBox.Show("Width needs to be numeric");
				return;
			}

			if (!txtTileHeight.Text.IsNumeric())
			{
				MessageBox.Show("Height needs to be numeric");
				return;
			}

			Name = txtName.Text;
			Width = Convert.ToInt32(txtTileWidth.Text);
			Height = Convert.ToInt32(txtTileHeight.Text);

			DialogResult = true;
		}

		private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
		{
			DialogResult = false;
		}
	}
}
